home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / displytl / slides.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  19.2 KB  |  646 lines

  1. /*
  2.  * Copyright (c) 1990, 1991, 1992 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23. /* $Header: /Source/Media/collab/DisplayTool/RCS/slides.c,v 1.11 93/02/07 17:52:41 drapeau Exp $ */
  24. /* $Log:    slides.c,v $
  25.  * Revision 1.11  93/02/07  17:52:41  drapeau
  26.  * Two changes:
  27.  * * Cosmetic changes, added calls to UpdateHeader() to indicate status of
  28.  *   currently open document.
  29.  * * Updated the InitSlide() function to properly initialize the string value
  30.  *   of the "duration" field for each slide.
  31.  * 
  32.  * Revision 1.1  92/10/29  13:58:09  drapeau
  33.  * Initial revision
  34.  *  */
  35. static char dtSlides[] = "$Header: /Source/Media/collab/DisplayTool/RCS/slides.c,v 1.11 93/02/07 17:52:41 drapeau Exp $";
  36.  
  37. #include "DisplayTool.h"
  38. #include "externs.h"
  39.  
  40.  
  41.  
  42. /*
  43.  * Event callback function for `slides'.
  44.  */
  45. Notify_value
  46.   DisplayTool_baseWindow_slides_event_callback(Xv_window win, Event *event, Notify_arg arg, Notify_event_type type)
  47. {
  48.   if (event_id(event) == LOC_DRAG) 
  49.   {
  50.     SlidesEventProc(win, event, arg, type);
  51.   }
  52.   /* gxv_start_connections DO NOT EDIT THIS SECTION */
  53.   
  54.   if (event_action(event) == ACTION_SELECT)
  55.   {
  56.     SlidesEventProc(win, event, arg, type);
  57.   }
  58.   
  59.   if (event_action(event) == ACTION_ADJUST)
  60.   {
  61.     SlidesEventProc(win, event, arg, type);
  62.   }
  63.   
  64.   if (event_action(event) == ACTION_MENU)
  65.   {
  66.     SlidesEventProc(win, event, arg, type);
  67.   }
  68.   
  69.   /* gxv_end_connections */
  70.   
  71.   return notify_next_event_func(win, (Notify_event) event, arg, type);
  72. }
  73.  
  74.  
  75.  
  76.  
  77. /*
  78.  * Called when an event is received in the slides canvas.
  79.  */
  80. Notify_value
  81.   SlidesEventProc(Xv_window win, Event *event, Notify_arg arg, Notify_event_type type)
  82. {
  83.   static int    first, dragging, i, dragFirst = TRUE;
  84.   static int    imageNum, selectionMade, resizing;
  85.   static int    oldRectWidth, oldRectHeight;
  86.   static XPoint    oldRectCorner;
  87.   static XPoint pointerOffset;
  88.   static int    slideOffsetX;
  89.   static int    slideOffsetY;
  90.   IMAGE        tempImage;
  91.   XPoint    loc;
  92.   int        width, height, effectiveWidth = None, effectiveHeight = None;
  93.   XEvent    compressedEvent;
  94.   
  95.   PrintDTDiagnostics("Entered SlidesEventProc.\n");
  96.   if (event_action(event) != event_id(event))                /* Same reasoning as with the GalleryEventProc */
  97.     {
  98.       switch (event_action(event)) 
  99.     {
  100.     case ACTION_SELECT :                        /* the action */
  101.     case MS_LEFT :                            /* the actual (literal) event */
  102.     case ACTION_ADJUST :
  103.     case MS_MIDDLE :
  104.     case ACTION_MENU :
  105.     case MS_RIGHT :
  106.       if (slideSize == Large)
  107.         notice_prompt(baseWindow->baseWindow, NULL,
  108.               NOTICE_MESSAGE_STRINGS,
  109.               "Please change 'Show Full Size' to NO before manipulating the slides.",
  110.               NULL,
  111.               NOTICE_BUTTON_YES, "OK",
  112.               NULL);
  113.       if (event_is_down(event))
  114.         SlideEventDown(event, &loc, &selectionMade, &imageNum, 
  115.                &resizing, &pointerOffset);
  116.           
  117.       else 
  118.         if (event_is_up(event))
  119.               {
  120.                 SlideEventUp(&resizing, &first, dragging, selectionMade,
  121.                  oldRectCorner, oldRectWidth, oldRectHeight);
  122.         imageNum      = None;
  123.         selectionMade = FALSE;
  124.         dragging      = FALSE;
  125.         dragFirst     = TRUE;
  126.         RedrawRectangles();
  127.           }
  128.       break;
  129.       default :
  130.         break;
  131.     }                                /* end switch (event_action(event)) */
  132.     }
  133.   else                                    /* Same reasoning as with the GalleryEventProc */
  134.     switch (event_id(event)) 
  135.       {
  136.       case LOC_DRAG:
  137.     if (imageNum == None)                        /* Was an image selected? */
  138.       break;                            /* No, get out of this loop now */
  139.     tempImage = dtImage[imageNum];
  140.     if (selectionMade)
  141.       {
  142.         dragging = TRUE;
  143.         if (resizing)
  144.           SlideEventResize(event, loc, &first, &oldRectCorner, &oldRectWidth, &oldRectHeight);
  145.         
  146.         else                            /* not resizing */
  147.           {
  148.         if (dragFirst)
  149.           {
  150.             GetEffectiveDimensions(dtImage[numSlidesImages - 1],
  151.                        &effectiveWidth, &effectiveHeight);
  152.             width  = (effectiveWidth > None)? effectiveWidth :
  153.               tempImage->origWidth / largeFactor;
  154.             height = (effectiveHeight > None)? effectiveHeight :
  155.               tempImage->origWidth / largeFactor;
  156.             dragFirst = FALSE;
  157.           }
  158.         else
  159.           {
  160.             width = tempImage->origWidth / largeFactor;
  161.             height = tempImage->origWidth / largeFactor;
  162.           }
  163.         GetOffsets(tempImage->slide,
  164.                &slideOffsetX, &slideOffsetY);
  165.         if (tempImage->imageData == (byte*)NULL)
  166.         {
  167.           BusyApp();                        /* Tell XView that the app is occupied */
  168.           dtImage[imageNum] = ReCreateImage(tempImage);
  169.           tempImage = dtImage[imageNum];
  170.           NormalApp();                        /* Tell XView that the app is ready-to-go again */
  171.         }
  172.         PaintSlideImage(tempImage, 0, 0,            /* Draw this image on the slidesWin */
  173.                 slideOffsetX + tempImage->corner.x,
  174.                 slideOffsetY + tempImage->corner.y);
  175.         tempImage->corner.x = (int)(event_x(event)-pointerOffset.x);
  176.         tempImage->corner.y = (int)(event_y(event)-pointerOffset.y);
  177.         PaintSlideImage(tempImage, 0, 0,            /* Draw this image on the slidesWin */
  178.                 slideOffsetX + tempImage->corner.x,
  179.                 slideOffsetY + tempImage->corner.y);
  180.         changes = TRUE;
  181.         UpdateHeader(True);
  182.           }
  183.       }
  184.     break;
  185.       default:
  186.     ;
  187.       }
  188.   if (display)
  189.     {
  190.       for (i=XEventsQueued(display, QueuedAlready); i>1; i--)
  191.     XNextEvent(display, &compressedEvent); 
  192.     }  
  193.   
  194.   /* gxv_start_connections DO NOT EDIT THIS SECTION */
  195.   
  196.   /* gxv_end_connections */
  197.   
  198.   return notify_next_event_func(win, (Notify_event) event, arg, type);
  199. }                                    /* end function SlidesEventProc */
  200.  
  201.  
  202.  
  203. int 
  204.   WhichImage(int x, int y)
  205. {
  206.   int i, xoffset, yoffset;
  207.   
  208.   GetOffsets(selectedSlide, &xoffset, &yoffset);
  209.   for (i=0; i<numSlidesImages; i++)
  210.     {
  211.       if (dtImage[i]->slide == selectedSlide)
  212.     {
  213.       if (x>=xoffset+dtImage[i]->corner.x && 
  214.           x<=xoffset+dtImage[i]->corner.x+(dtImage[i]->largeWidth / largeFactor) && 
  215.           y>=yoffset+dtImage[i]->corner.y && 
  216.           y<=yoffset+dtImage[i]->corner.y+(dtImage[i]->largeHeight / largeFactor))
  217.       {
  218.         sprintf(diagString, "In WhichImage, Image selected is %d.\n", i);
  219.         PrintDTDiagnostics(diagString);
  220.         return i;
  221.       }
  222.     }
  223.     }
  224.   return None;
  225. }                                    /* end function WhichImage */
  226.  
  227.  
  228.  
  229. /*
  230.  *  called from SlidesEventProc ...
  231.  */
  232. void
  233.   SlideEventDown(Event*        event,
  234.          XPoint*    loc,
  235.          int*        selectionMade,
  236.          int*        imageNum,
  237.          int*        resizing,
  238.          XPoint*    pointerOffset)
  239. {
  240.   XPoint    adjustedLoc;
  241.   int        xoffset, yoffset;
  242.   IMAGE        tempImage;
  243.   
  244.   loc->x = event_x(event);
  245.   loc->y = event_y(event);
  246.   previousSlide = selectedSlide;
  247.   
  248.   if ((selectedSlide = WhichSlide(loc->x, loc->y, slideSize, &adjustedLoc)) < MaxNumSlides)
  249.     {
  250.       RedrawRectangles();
  251.       xv_set(slidePopup->duration,
  252.          PANEL_VALUE,
  253.          slide[selectedSlide]->duration,
  254.          NULL);
  255.       if (slide[selectedSlide]->label)
  256.     if (strncmp(slide[selectedSlide]->label, "No Label", 8) != 0)
  257.       xv_set(slidePopup->label, PANEL_VALUE, slide[selectedSlide]->label, NULL);
  258.     else
  259.       xv_set(slidePopup->label, PANEL_VALUE, "", NULL);
  260.       SetCurrentSlide(selectedSlide+1);
  261.     }
  262.   if (*selectionMade == FALSE)
  263.     {
  264.       if ((*imageNum = WhichImage(loc->x, loc->y)) != None)
  265.     {
  266.       tempImage = dtImage[*imageNum];
  267.       
  268.       if (event_action(event)==ACTION_MENU || event_action(event)==MS_RIGHT)
  269.         *resizing = TRUE;
  270.       else
  271.         *resizing = FALSE;
  272.       *selectionMade = TRUE;
  273.       
  274.       GetOffsets(numSlidesImages-1, &xoffset, &yoffset);
  275.       if (tempImage->imageData == (byte*)NULL)
  276.       {
  277.         BusyApp();                                /* Tell XView that the app is occupied */
  278.         dtImage[*imageNum] = ReCreateImage(tempImage);
  279.         tempImage = dtImage[*imageNum];
  280.         NormalApp();                        /* Tell XView that the app is ready-to-go again */
  281.       }
  282.       PaintSlideImage(tempImage, 0, 0,                /* Draw this image on the slidesWin */
  283.               tempImage->corner.x,
  284.               tempImage->corner.y);
  285.       pointerOffset->x = loc->x - tempImage->corner.x;
  286.       pointerOffset->y = loc->y - tempImage->corner.y;
  287.       PaintSlideImage(tempImage, 0, 0,                /* Draw this image on the slidesWin */
  288.               loc->x-pointerOffset->x,
  289.               loc->y-pointerOffset->y);
  290.       changes = TRUE;
  291.       UpdateHeader(True);
  292.     }
  293.     } 
  294. }                                    /* end function SlideEventDown */
  295.  
  296.  
  297. /*
  298.  *  called from SlidesEventProc ....
  299.  */
  300. void
  301.   SlideEventUp(int*    resizing,
  302.            int*    first,
  303.            int    dragging,
  304.            int    selectionMade,
  305.            XPoint    oldRectCorner,
  306.            int    oldRectWidth,
  307.            int    oldRectHeight)
  308. {
  309.   int    whichImageNum = None;
  310.   char    errorMessage[MaxLength];
  311.   IMAGE    tempImage;
  312.   
  313.   whichImageNum = WhichImage(oldRectCorner.x, oldRectCorner.y);        /* Try to determine which image was being pressed */
  314.   if (whichImageNum == None)                        /* No image?  Return immediately without doing anything */
  315.     return;
  316.   tempImage = dtImage[whichImageNum];
  317.   if (*resizing && dragging)
  318.     {
  319.       XDrawRectangle(display, slidesWin, theGC,
  320.              oldRectCorner.x, oldRectCorner.y, 
  321.              oldRectWidth, oldRectHeight);
  322.       if (tempImage->imageData == (byte*)NULL)
  323.       {
  324.     BusyApp();                            /* Tell XView that the app is occupied */
  325.     dtImage[whichImageNum] = ReCreateImage(tempImage);
  326.     tempImage = dtImage[whichImageNum];
  327.     NormalApp();                            /* Tell XView that the app is ready-to-go again */
  328.       }
  329.       PaintSlideImage(tempImage, 0, 0,                    /* Draw this image on the slidesWin */
  330.               tempImage->corner.x,
  331.               tempImage->corner.y);
  332.       tempImage->corner.x = oldRectCorner.x; 
  333.       tempImage->corner.y = oldRectCorner.y; 
  334.       PaintSlideImage(tempImage, 0, 0,                    /* Draw this image on the slidesWin */
  335.               tempImage->corner.x,
  336.               tempImage->corner.y);
  337.       if (numSlidesImages > 0 && selectionMade)
  338.     {
  339.       tempImage->slide = 
  340.         WhichSlide(tempImage->corner.x, 
  341.                tempImage->corner.y,
  342.                slideSize, &tempImage->corner);
  343.       if (tempImage->slide > MaxNumSlides-1)
  344.         {
  345.           sprintf(errorMessage, "Can't exceed %d slides.", MaxNumSlides);
  346.           notice_prompt(baseWindow->baseWindow, NULL,
  347.                 NOTICE_MESSAGE_STRINGS,
  348.                 errorMessage,
  349.                 " ",
  350.                 "Images beyond this limit shall",
  351.                 "be placed in the last slide.",
  352.                 NULL,
  353.                 NOTICE_BUTTON_YES, "OK",
  354.                 NULL);
  355.           tempImage->slide = MaxNumSlides - 1;
  356.           SlidesRepaint(NULL, NULL, NULL, NULL);
  357.         }
  358.       SetTotalNumberOfSlides();
  359.     }
  360.       XSetFunction(display, theGC, GXxor); 
  361.       changes  = TRUE;
  362.       UpdateHeader(True);
  363.       *first    = FALSE;
  364.       *resizing = FALSE;
  365.     }
  366.   else
  367.     {
  368.       if (numSlidesImages > 0 && selectionMade)
  369.     {
  370.       tempImage->slide =
  371.         WhichSlide(tempImage->corner.x, 
  372.                tempImage->corner.y,
  373.                slideSize, &tempImage->corner);
  374.       
  375.       if (tempImage->slide > MaxNumSlides-1)
  376.         {
  377.           sprintf(errorMessage, "Can't exceed %d slides.", MaxNumSlides);
  378.           notice_prompt(baseWindow->baseWindow, NULL,
  379.                 NOTICE_MESSAGE_STRINGS,
  380.                 errorMessage,
  381.                 " ",
  382.                 "Images beyond this limit shall",
  383.                 "be placed in the last slide.",
  384.                 NULL,
  385.                 NOTICE_BUTTON_YES, "OK",
  386.                 NULL);
  387.           tempImage->slide = MaxNumSlides - 1;
  388.           SlidesRepaint(NULL, NULL, NULL, NULL);
  389.         }
  390.       SetTotalNumberOfSlides();
  391.       selectedSlide = tempImage->slide;
  392.       SetCurrentSlide(selectedSlide+1);
  393.     }
  394.     }
  395. }                                    /* end function SlideEventUp */
  396.  
  397.  
  398. /*
  399.  *
  400.  */
  401. void
  402.   SlideEventResize(Event *event, XPoint loc, int *first, XPoint *oldRectCorner, 
  403.            int *oldRectWidth, int *oldRectHeight)
  404. {
  405.   int        rectWidth, rectHeight;
  406.   int        whichImageNum = None;
  407.   XPoint    rectCorner;
  408.   IMAGE        tempImage;
  409.   
  410.   whichImageNum = WhichImage(oldRectCorner->x, oldRectCorner->y);   /* Try to determine which image was being pressed */
  411.   if (whichImageNum == None)                        /* No image?  Return immediately without doing anything */
  412.     return;
  413.   tempImage = dtImage[whichImageNum];
  414.   if (loc.x > (tempImage->corner.x + 
  415.            (int)((tempImage->largeWidth / largeFactor)/2.0)))
  416.     {
  417.       rectCorner.x = tempImage->corner.x;
  418.       rectWidth = event_x(event)- tempImage->corner.x;
  419.     }
  420.   else 
  421.     {
  422.       rectCorner.x = event_x(event);
  423.       rectWidth    = (tempImage->largeWidth / largeFactor) -
  424.     (event_x(event)- tempImage->corner.x);
  425.     }
  426.   if (loc.y > tempImage->corner.y + 
  427.       (int)((tempImage->largeHeight / largeFactor) / 2.0))
  428.     {
  429.       rectCorner.y = tempImage->corner.y;
  430.       rectHeight = event_y(event)- tempImage->corner.y;
  431.     }
  432.   else 
  433.     {
  434.       rectCorner.y = event_y(event);
  435.       rectHeight   = (tempImage->largeHeight / largeFactor) -
  436.     (event_y(event)- tempImage->corner.y);
  437.     }
  438.   if (*first)
  439.     XDrawRectangle(display, slidesWin, theGC,
  440.            oldRectCorner->x, oldRectCorner->y, 
  441.            *oldRectWidth, *oldRectHeight);
  442.   else 
  443.     *first = TRUE;
  444.   
  445.   if (rectCorner.x > (tempImage->corner.x + 
  446.               (tempImage->largeWidth / largeFactor) - 4))
  447.     rectCorner.x = (tempImage->corner.x + 
  448.             (tempImage->largeWidth / largeFactor) - 4);
  449.   
  450.   if (rectCorner.y > (tempImage->corner.y + 
  451.               (tempImage->largeHeight / largeFactor) - 4))
  452.     rectCorner.y = (tempImage->corner.y + 
  453.             (tempImage->largeHeight / largeFactor) - 4);
  454.   
  455.   if (rectWidth  < 4)
  456.     rectWidth  = 4;
  457.   if (rectHeight < 4)
  458.     rectHeight = 4;
  459.   if (rectWidth  > SmallWidth  - 5)
  460.     rectWidth  = SmallWidth  - 5;
  461.   if (rectHeight > SmallHeight - 5)
  462.     rectHeight = SmallHeight - 5;
  463.   
  464.   XDrawRectangle(display, slidesWin, theGC,
  465.          rectCorner.x, rectCorner.y,
  466.          rectWidth, rectHeight);
  467.   
  468.   oldRectCorner->x = rectCorner.x; 
  469.   oldRectCorner->y = rectCorner.y; 
  470.   *oldRectWidth    = rectWidth; 
  471.   *oldRectHeight   = rectHeight; 
  472.   changes         = TRUE;
  473.   UpdateHeader(True);
  474. }                                    /* end function SlideEventResize */
  475.  
  476.  
  477. int 
  478.   WhichSlide(int x, int y, int size, XPoint *corner)
  479. {
  480.   int    theSlide = 0;
  481.   
  482.   if (size == Small)
  483.     {
  484.       if (corner)
  485.     {
  486.       corner->x = x % SmallWidth;
  487.       corner->y = y % SmallHeight;
  488.     }
  489.       theSlide = (x / SmallWidth) + (SlidesPerRow * (y / SmallHeight));
  490.     }
  491.   else if (size == Large)
  492.     {
  493.       if (corner)
  494.     {
  495.       corner->x = (int)(x / largeFactor);
  496.       corner->y = (int)((y % FullHeight) / largeFactor);
  497.     }
  498.       theSlide = (int)(y / FullHeight);
  499.     }
  500.   sprintf(diagString, "In WhichSlide, theSlide is %d.\n", theSlide);
  501.   return(theSlide);
  502. }                                    /* end function WhichSlide */
  503.  
  504.  
  505.  
  506. /*
  507.  * Repaint callback function for `slides'.
  508.  */
  509. void
  510.   SlidesRepaint(Canvas canvas, Xv_window paint_window, 
  511.         Window xid, Xv_xrectlist *rects)
  512. {
  513.   int    i;
  514.   
  515.   PrintDTDiagnostics("Entering SlidesRepaint.\n");
  516.   BusyApp();                                /* Tell XView that the app is occupied */
  517.   XClearArea(display, slidesWin, 0, 0, (int)xv_get(baseWindow->slides, CANVAS_WIDTH),
  518.          (int)xv_get(baseWindow->slides, CANVAS_HEIGHT), True); 
  519.   if (slideSize == Small)
  520.   {
  521.     for (i = 0; i < MaxNumSlides; i++)
  522.     {
  523.       PaintSlide(i);
  524.     }                                    /* end for... */
  525.     RedrawRectangles();
  526.   }
  527.   XFlush(display);
  528.   NormalApp();                                /* Tell XView that the app is ready-to-go again */
  529. }                                    /* end function SlidesRepaint */
  530.  
  531.  
  532.  
  533. void
  534.   RedrawRectangles(void)
  535. {
  536.   int i;
  537.   if (!display)
  538.     return;
  539.   XSetLineAttributes(display, theGC, 2, LineSolid, CapProjecting, JoinMiter);
  540.   XSetFunction(display, theGC, GXcopy); 
  541.   XSetForeground(display, theGC, BlackPixel(display, DefaultScreen(display)));
  542.   for (i=0; i< MaxNumSlides; i++)
  543.     {
  544.       if (i == selectedSlide)
  545.     XSetForeground(display, theGC, pixelValues[Red]);
  546.       XDrawRectangle(display, slidesWin, theGC, 
  547.              (i%SlidesPerRow)*(SmallWidth-4)+4*(i%SlidesPerRow)+1, 
  548.              (i/SlidesPerRow)*(SmallHeight-4)+4*(i/SlidesPerRow)+1, 
  549.              SmallWidth-3, SmallHeight-3);
  550.       if (i == selectedSlide)
  551.     XSetForeground(display, theGC, BlackPixel(display, DefaultScreen(display)));
  552.     }
  553.   XSetFunction(display, theGC, GXxor); 
  554. }
  555.  
  556.  
  557. void InitSlide(SCR theSlide)
  558. {
  559.   int    i;
  560.   
  561.   theSlide->duration = "Indefinite";
  562.   theSlide->label = NULL;
  563.   theSlide->numberOfImages = 0;
  564.   for (i = 0; i < MaxNumImages / 2; i++)
  565.     theSlide->imageIds[i] = 0;
  566.   return;
  567. }                                    /* end function InitSlide */
  568.  
  569.  
  570. void
  571.   GetOffsets(int i, int *xoffset, int *yoffset)
  572. {
  573.   if (slideSize == Small)
  574.     {
  575.       *xoffset = SmallWidth*(i % SlidesPerRow);
  576.       *yoffset = SmallHeight*(i / SlidesPerRow);
  577.     }
  578.   else                                    /*  slideSize == Large */
  579.     {
  580.       *xoffset = 0;
  581.       *yoffset = 0;    
  582.     }
  583. }                                    /* end function GetOffsets */
  584.  
  585. void PaintSlideImage(IMAGE        theImage,            /* This function paints the slide specified by... */
  586.              int        srcX,                /* ..."theImage->slideImage" onto the appropriate slide... */
  587.              int        srcY,                /* ...in the Slides window. */
  588.              int        destX,
  589.              int        destY)
  590. {
  591.   int    effectiveWidth;
  592.   int    effectiveHeight;
  593.   
  594.   effectiveWidth = theImage->largeWidth / largeFactor;
  595.   effectiveHeight = theImage->largeHeight / largeFactor;
  596.   GetEffectiveDimensions(theImage,                    /* Determine the width to use for drawing this image... */
  597.              &effectiveWidth, &effectiveHeight);        /* ...on its slide */
  598.   if (theImage->slideImage == (XImage*)NULL)                /* If the slideImage doesn't exist, create it first. */
  599.     theImage->slideImage = Resize(theImage->imageData,
  600.                   theImage->origWidth,
  601.                   theImage->origHeight,
  602.                   theImage->largeWidth / largeFactor,
  603.                   theImage->largeHeight / largeFactor);
  604.   XPutImage(display, slidesWin, theGC, 
  605.         theImage->slideImage,
  606.         srcX, srcY, destX, destY,
  607.         effectiveWidth, effectiveHeight);
  608. }                                    /* end function PaintSlideImage */
  609.  
  610.  
  611.  
  612. void PaintSlide(int slideNum)
  613. {
  614.   int        i;
  615.   int        xOffset;
  616.   int        yOffset;
  617.   IMAGE        tempImage = (IMAGE)NULL;
  618.   int        tempSlide, width, height;
  619.   int        hold;
  620.   XPoint    corner;
  621.   
  622.   sprintf(diagString, "Entering PaintSlide, slide %d.\n", slideNum);
  623.   PrintDTDiagnostics(diagString);
  624.   if (performing != 0)                            /* Don't redraw slides during performance of MAEstro... */
  625.     return;                                /* ...messages */
  626.   GetOffsets(slideNum, &xOffset, &yOffset);                /* Determine coordinates in which to draw slides */
  627.   XClearArea(display, slidesWin, xOffset, yOffset,
  628.          SmallWidth, SmallHeight, True);
  629.   for (i = 0; i < numSlidesImages; i++)
  630.   {
  631.     if (dtImage[i]->slide == slideNum)                    /* Does this dtImage belong in this slide? */
  632.     {
  633.       if (dtImage[i]->imageData == (byte*)NULL)                /* Is this image empty? */
  634.       {                                    /* Yes, create it on demand before trying to draw it. */
  635.     sprintf(diagString, "In PaintSlide, creating image %d (file: %s) on demand.\n",
  636.         i, dtImage[i]->filename);
  637.     PrintDTDiagnostics(diagString);
  638.     dtImage[i] = ReCreateImage(dtImage[i]);
  639.       }                                    /* end if image doesn't yet exist */
  640.       PaintSlideImage(dtImage[i], 0, 0,                    /* Yes, paint this image in this slide */
  641.               xOffset + dtImage[i]->corner.x,
  642.               yOffset + dtImage[i]->corner.y);
  643.     }                                    /* end if this image belongs in this slide */
  644.   }                                    /* end for */
  645. }                                    /* end function PaintSlide */
  646.